<script>
import outMain from "@/components/outMain.vue";
import { ElMessage, ElMessageBox, ElLoading } from "element-plus";
import { authRecord } from "@/http/api";

export default {
  components: { outMain },
  name: "",
  data() {
    return {
      statusArr: [
        { label: "授权失败", value: 0 },
        { label: "授权成功", value: 1 },
      ],
      tableData: [
        {
          authOrginNum: "1276278368",
          authNum: "57863823",
          userName: "四川省本地鸟科技有限公司",
          channelName: "浙江省杭州市渠道商",
          sealCode: "21483749273",
          status: "授权成功",
          create_time: "2025-03-11 51:31:44",
        },
      ],
      queryData: {
        user_name: "",
        page: 1,
        per_page: 10,
      },
      total: 0,
    };
  },
  props: {},
  setup() {},
  methods: {
    serchFn() {
      this.queryData.page = 1;
      this.getData();
    },
    getData() {
      const loading = ElLoading.service({
        lock: true,
        text: "Loading",
        background: "rgba(255, 255, 255, 0.7)",
      });
      authRecord(this.queryData).then((res) => {
        setTimeout(() => {
          loading.close();
        }, 100);
        if (res.data.code == 1) {
          this.tableData = res.data.data.data;
          this.total = res.data.data.total;
        }
      });
    },
  },
  mounted() {},
  async created() {
    this.getData();
  },
};
</script>
<template>
  <outMain>
    <div class="tableCont">
      <div class="tableName flexCont">
        <div>授权溯源列表（{{ total }}）</div>
      </div>
      <div class="tableSerch">
        <div class="serchLeft"></div>
        <div class="serchRight">
          <el-form class="flexCenter" :inline="true">
            <el-form-item>
              <el-input
                clearable
                @clear="getData"
                @keyup.enter="getData"
                v-model="queryData.nick_name"
                placeholder="授权编号"
              />
            </el-form-item>
            <el-form-item>
              <el-input
                clearable
                @clear="getData"
                @keyup.enter="getData"
                v-model="queryData.nick_name"
                placeholder="授权用户"
              />
            </el-form-item>
            <el-form-item>
              <el-input
                clearable
                @clear="getData"
                @keyup.enter="getData"
                v-model="queryData.nick_name"
                placeholder="渠道商名称"
              />
            </el-form-item>
            <el-form-item>
              <el-input
                clearable
                @clear="getData"
                @keyup.enter="getData"
                v-model="queryData.nick_name"
                placeholder="印章ID"
              />
            </el-form-item>
            <el-form-item>
              <el-select v-model="queryData.nick_name" placeholder="授权状态">
                <el-option
                  v-for="item in statusArr"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-button class="hasBottom" type="primary" @click="serchFn">
              <span class="iconfont icon-sousuo"></span>
              <span>搜索</span>
            </el-button>
          </el-form>
        </div>
      </div>
      <el-table class="tableMain" :data="tableData" stripe>
        <el-table-column
          prop="authorization_trace_id"
          width="120"
          show-overflow-tooltip
          label="授权溯源ID"
        />
        <el-table-column
          prop="authorization_batch_id"
          width="120"
          show-overflow-tooltip
          label="授权编号"
        />
        <el-table-column
          prop="user_name"
          width="240"
          show-overflow-tooltip
          label="授权用户"
        />
        <el-table-column
          prop="channel_name"
          show-overflow-tooltip
          label="渠道商"
        />
        <el-table-column
          prop="seal_id"
          width="200"
          show-overflow-tooltip
          label="授权印章ID"
        />
        <el-table-column label="授权状态">
          <template #default="{ row }">
            <el-tag type="success" v-if="row.authorization_status == 1"
              >授权成功</el-tag
            >
            <el-tag type="danger" v-if="row.authorization_status == 2"
              >授权成功</el-tag
            >
          </template>
        </el-table-column>
        <el-table-column
          prop="authorization_time"
          width="180"
          show-overflow-tooltip
          label="授权时间"
        />
      </el-table>
      <div class="pageCont">
        <el-pagination
          v-model:currentPage="queryData.page"
          v-model:page-size="queryData.per_page"
          background
          small
          layout="total, prev, pager, next, jumper"
          :total="total"
          @size-change="getData"
          @current-change="getData"
        />
      </div>
    </div>
  </outMain>
</template>
<style scoped lang="less"></style>
